﻿using System;
using System.Collections.Generic;

using PlugNT.Custom;
using PlugNT.Common;
namespace PlugNT.Cms.Model
{
    /// <summary>
    /// 模型表实体
    /// </summary>
    public abstract class SysModelInfo
    {
        
        //不是自动ID
        public int id;
        //类型名称
        public string name;
        /// <summary>
        /// 类型(SysModelType.Info = 0,SysModelType.Shop = 1,SysModelType.Bbs = 2)
        /// </summary>
        public int type;
        //是否可用
        public bool enable;
        //是否固定
        public bool is_fixed;
        //栏目编号列表
        public string channel_no_list;


        //禁用审核
        public bool msg_locked = false;
        //禁用图片
        public bool image_locked = false;
        //发帖方式
        public int msg_style ;
        //访问最大数
        public int visit_max_count;
        //访问最大数时间
        public DateTime visit_max_time;

        //xml
        public string arr_str;
        public SysModelInfo() { }


        public abstract void ArrBind();

    }


    public class InfoModelInfo : SysModelInfo
    {
        //是否生成静态
        public bool is_create_static = false;
        //生成静态是否压缩
        public bool is_ziphtml = false;

        public override void ArrBind()
        {
            string[] sArr = arr_str.Split(',');
            int tLen = sArr.Length;
            int tFlag = 0;
            is_create_static = (tLen > tFlag) ? sArr[tFlag] == "1" : false;
            is_ziphtml = (tLen > ++tFlag) ? sArr[tFlag] == "1" : false;
        }
    }

    public class ShopModelInfo : SysModelInfo
    {

        //支付宝合作者身份ID
        public string pay_alipay_id = "";
        //支付宝接口方式
        public string pay_alipay_type = "";
        //支付宝帐号
        public string pay_alipay_account = "";
        //支付宝校验码
        public string pay_alipay_password = "";
        //网银在线商户ID
        public string pay_chinabank_account = "";
        //网银在线交易密钥
        public string pay_chinabank_password = "";
        //财付通商户ID
        public string pay_tenpay_account = "";
        //财付通交易密钥
        public string pay_tenpay_password = "";

        public override void ArrBind()
        {
            string[] sArr = arr_str.Split(',');
            int tLen = sArr.Length;
            int tFlag = 0;
            pay_alipay_id = (tLen > tFlag) ? sArr[tFlag] : "";
            pay_alipay_type = (tLen > ++tFlag) ? sArr[tFlag] : "";
            pay_alipay_account = (tLen > ++tFlag) ? sArr[tFlag] : "";
            pay_alipay_password = (tLen > ++tFlag) ? sArr[tFlag] : "";
            pay_chinabank_account = (tLen > ++tFlag) ? sArr[tFlag] : "";
            pay_chinabank_password = (tLen > ++tFlag) ? sArr[tFlag] : "";
            pay_tenpay_account = (tLen > ++tFlag) ? sArr[tFlag] : "";
            pay_tenpay_password = (tLen > ++tFlag) ? sArr[tFlag] : "";
        }

    }

    public class BbsModelInfo : SysModelInfo
    {
        //允许用户积分
        public int user_look_integral = -1;
        public int user_add_integral = -1;
        public int user_upt_integral = -1;
        public int user_del_integral = -1;

        public int user_add_topic_integral;
        public int user_add_reply_integral;
        public int user_add_commend_topic_integral;
        public int user_del_topic_integral;
        public int user_del_reply_integral;
        public int user_del_commend_topic_integral;
        public int user_reg_integral;
        public int user_log_integral;

        public override void ArrBind()
        {
            string[] sArr = arr_str.Split(',');
            int tLen = sArr.Length;
            int tFlag = 0;
            user_look_integral = (tLen > tFlag) ? (Utils.IsNumeric(sArr[tFlag]) ? int.Parse(sArr[tFlag]) : -1) : -1;
            user_add_integral = (tLen > ++tFlag) ? (Utils.IsNumeric(sArr[tFlag]) ? int.Parse(sArr[tFlag]) : -1) : -1;
            user_upt_integral = (tLen > ++tFlag) ? (Utils.IsNumeric(sArr[tFlag]) ? int.Parse(sArr[tFlag]) : -1) : -1;
            user_del_integral = (tLen > ++tFlag) ? (Utils.IsNumeric(sArr[tFlag]) ? int.Parse(sArr[tFlag]) : -1) : -1;

            user_add_topic_integral = (tLen > ++tFlag) ? (Utils.IsNumeric(sArr[tFlag]) ? int.Parse(sArr[tFlag]) : 0) : 0;
            user_add_reply_integral = (tLen > ++tFlag) ? (Utils.IsNumeric(sArr[tFlag]) ? int.Parse(sArr[tFlag]) : 0) : 0;
            user_add_commend_topic_integral = (tLen > ++tFlag) ? (Utils.IsNumeric(sArr[tFlag]) ? int.Parse(sArr[tFlag]) : 0) : 0;
            user_del_topic_integral = (tLen > ++tFlag) ? (Utils.IsNumeric(sArr[tFlag]) ? int.Parse(sArr[tFlag]) : 0) : 0;
            user_del_reply_integral = (tLen > ++tFlag) ? (Utils.IsNumeric(sArr[tFlag]) ? int.Parse(sArr[tFlag]) : 0) : 0;
            user_del_commend_topic_integral = (tLen > ++tFlag) ? (Utils.IsNumeric(sArr[tFlag]) ? int.Parse(sArr[tFlag]) : 0) : 0;
            user_reg_integral = (tLen > ++tFlag) ? (Utils.IsNumeric(sArr[tFlag]) ? int.Parse(sArr[tFlag]) : 0) : 0;
            user_log_integral = (tLen > ++tFlag) ? (Utils.IsNumeric(sArr[tFlag]) ? int.Parse(sArr[tFlag]) : 0) : 0;
        }

    }


}
